package com.lengxf.job.dynamicTask.finder;

import com.lengxf.job.dynamicTask.DynamicTask;
import com.lengxf.job.dynamicTask.Task;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@AllArgsConstructor
public class TaskFinder {

    private final List<DynamicTask> dynamicTaskList;

    public DynamicTask findTask(Task task) {
        return dynamicTaskList.stream()
                .filter(e -> e.taskType().equals(task.getType()))
                .findFirst()
                .orElse(new LogTaskDynamicTask());
    }

}
